import { fallbackRequestGet, fallbackRequestPost } from '@/utils/Request'

/**
 * 请求前缀，后面后台添加网关后需要前缀选择微服务
 */
const URL_PREFIX = 'middle-user/'

/**
 * 获取当前登陆账户基本信息
 * @param {Function} successCallback 成功回调，参数为data
 * @param {Function} fullCallback 肯定触发的回调，先于callback
 */
export const queryCurrentUserInfo = (successCallback = null, fullCallback = null) => {
  const params = {}
  return fallbackRequestGet(URL_PREFIX + 'userInfo/queryCurrentUserInfo', params, {}, true, successCallback, null, fullCallback)
}

/**
 * 更改当前登陆账户基本信息
 * @param {UserInfoChgDTO} userInfoChgDTO 更改用户信息DTO
 * @param {Function} successCallback 成功回调，参数为data
 * @param {Function} fullCallback 肯定触发的回调，先于callback
 */
export const updateCurrentUserInfo = (userInfoChgDTO, successCallback = null, fullCallback = null) => {
  const params = Object.assign(userInfoChgDTO, {})
  return fallbackRequestPost(URL_PREFIX + 'userInfo/updateCurrentUserInfo', params, {}, true, successCallback, null, fullCallback)
}

/**
 * UserInfo相关接口
 * @type {{updateCurrentUserInfo: (function(UserInfoChgDTO, Function=, Function=): *), queryCurrentUserInfo: (function(Function=, Function=): *)}}
 */
export const userInfoController = {
  queryCurrentUserInfo,
  updateCurrentUserInfo
}

export default userInfoController
